package com.wzx.user.controller;

import com.wzx.common.core.controller.AbstractCoreController;
import com.wzx.common.pojo.resp.Result;
import com.wzx.user.mongo.SendMsg;
import com.wzx.user.mongo.req.SysMsgReq;
import com.wzx.user.pojo.SystemMsg;
import com.wzx.user.service.SystemMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wzx
 * @version 1.0
 * @date 2023/6/1 - 23:18
 * @description 标题
 */
@Slf4j
@RestController
@RequestMapping("/systemMsg")
@Api(tags = "系统消息管理")
public class SystemMsgController extends AbstractCoreController<SystemMsg> {

    @Autowired
    private SystemMsgService systemMsgService;

    @Autowired
    protected SystemMsgController(SystemMsgService systemMsgService) {
        super(systemMsgService);
        this.systemMsgService = systemMsgService;
    }

    @ApiOperation(value = "通过账号搜索")
    @PostMapping("/getMsgBySystem")
    public Result getMsgBySystem(@RequestBody SysMsgReq sysMsgReq) {
        return systemMsgService.getMsgBySystem(sysMsgReq);
    }

    @ApiOperation(value = "清空所有系统消息")
    @GetMapping("/cleanAll")
    public Result cleanAll(Integer userId) {
        systemMsgService.cleanAll(userId);
        return Result.ok();
    }

    @ApiOperation(value = "添加好友")
    @PostMapping("/addFriend")
    public Result addFriend(@RequestBody SystemMsg systemMsg) {
        systemMsgService.addFriend(systemMsg);
        return Result.ok();
    }

    @ApiOperation(value = "加入群聊")
    @PostMapping("/addGroup")
    public Result addGroup(@RequestBody SystemMsg systemMsg) {
        systemMsgService.addGroup(systemMsg);
        return Result.ok();
    }

}
